package com.yurun.controller.admin;

import com.yurun.entity.SiteSetting;
import com.yurun.model.vo.Result;
import com.yurun.service.SiteSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin")
public class SiteSettingController {
    @Autowired
    SiteSettingService siteSettingService;
    /**
     * @Description: 添加站点设置
     * @Param: siteSetting
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @PostMapping("/sitesetting")
    public Result addSiteSetting(@RequestBody  SiteSetting siteSetting){
        siteSettingService.addSiteSetting(siteSetting);
        return Result.ok("添加站点设置成功");
    }
    /**
     * @Description: 通过ID-删除站点设置
     * @Param: id
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @DeleteMapping("/sitesetting/id")
    public Result deleteSiteSettingById(@RequestParam Integer id){
        siteSettingService.deleteSiteSettingById(id);
        return Result.ok("删除站点设置成功");
    }
    /**
     * @Description: 更新站点设置
     * @Param: siteSetting
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @PutMapping("/sitesetting")
    public Result updateSiteSetting(@RequestBody SiteSetting siteSetting){
        siteSettingService.updateSiteSetting(siteSetting);
        return Result.ok("更新站点设置成功");
    }
    /**
     * @Description: 获取站点设置列表
     * @Param:
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @GetMapping("/sitesettinglist")
    public Result getList(){
        List<SiteSetting> object=siteSettingService.getList();
        return Result.ok("请求网站设置数据列表成功",object);
    }
}
